﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Web.Http;
using AttributeRouting.Web.Http;
using WS.EKA.Core.DI;
using WS.EKA.Model;
using WS.EKA.ServiceInterface;
using WS.EKA.Utilities.Consts;
using WS.EKA.Portal.Filters;
using System.Net;

namespace WS.EKA.Portal.Controllers
{
    public class ShoppingCartController : ApiController
    {
        private IShoppingCart shoppingCart;

        public ShoppingCartController(IShoppingCart shoppingCart)
        {
            this.shoppingCart = shoppingCart;
        }

       
        [GET("api/shoppingcart/{loginId}")]
        public List<ShoppingCart> GetByMember(string loginId)
        {
            var result = shoppingCart.GetByMember(loginId);
            return result;
        }

        public HttpStatusCode Post(ShoppingCart product)
        {
            shoppingCart.Add(product);
            return HttpStatusCode.Accepted;
        }

        public HttpStatusCode Put(ShoppingCart product)
        {
            shoppingCart.Update(product);
            return HttpStatusCode.Accepted;
        }

        [DELETE("api/shoppingcart/{loginId}/{productId}")]
        public HttpStatusCode Delete(string loginId, Guid productId)
        {
            shoppingCart.Delete(loginId, productId);
            return HttpStatusCode.OK;
        }
    }
}
